// 处理相应的父子数据
export function toTreeData(data) {
	let resData = data;
	let tree = [];

	for (let i = 0; i < resData.length; i++) {
			if (resData.filter(item => resData[i].parent_code == item.code).length == 0) {
					let obj = {
							value: resData[i].code,
							key: resData[i].code.toString(),
							title: resData[i].name,
							code: resData[i].code,
							parent_code: resData[i].parent_code,
							slots: {
									icon: 'global',
							},
							children: []
					};
					tree.push(obj);
					// resData.splice(i, 1);
			}

	}
	run(tree);

	function run(chiArr) {
			if (resData.length !== 0) {
					for (let i = 0; i < chiArr.length; i++) {
							for (let j = 0; j < resData.length; j++) {
									if (chiArr[i].code == resData[j].parent_code) {

											let obj = {
													value: resData[j].code,
													key: resData[j].code,
													title: resData[j].name,
													code: resData[j].code,
													slots: {
															icon: 'environment',
													},
													parent_code: resData[j].parent_code,
													children: []
											};
											chiArr[i].children.push(obj);
											resData.splice(j, 1);
											j--;
									}
							}
							run(chiArr[i].children);
					}
			}
	}

	return tree;
}